package cn.jsc.quartz.config;

import org.springframework.boot.autoconfigure.quartz.QuartzDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * 说明主数据库 和 次数据库
 */
@Configuration//这是一个配置类
	public class QuartzDataSourceConfig {

	    //主数据源
	    @Bean
	    @Primary //主数据库，指向pethome
	    @ConfigurationProperties(prefix = "spring.datasource")
	    public DataSource dataSource(){
	        return DataSourceBuilder.create().build();
	    }

	    //为quartz创建一个自己数据源
	    @Bean
	    @QuartzDataSource //quartz数据源
	    @ConfigurationProperties(prefix = "spring.quartz.properties.org.quartz.datasource")
	    public DataSource quartzDataSource(){
	        return DataSourceBuilder.create().build();
	    }
	}